package com.cskaoyan.market.controller;

import com.cskaoyan.market.db.domain.MarketBrand;
import com.cskaoyan.market.service.WxBrandService;
import com.cskaoyan.market.util.JacksonUtil;
import com.cskaoyan.market.util.ResponseUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author XuFeiLong
 * @DATE: 2023/4/1
 * @TIME: 16:06
 */
@RestController
@RequestMapping("wx/brand/")
public class WxBrandController {


    @Autowired
    WxBrandService wxBrandService;

    /**
     * 获取品牌列表
     *
     * @return
     */
    @GetMapping("list")
    public Object list(Integer page, Integer limit) {

        List<MarketBrand> result = wxBrandService.list(page, limit);
        // 对数据进行校验
        if (result == null) {
            return ResponseUtil.badArgument();
        }
        return ResponseUtil.okList(result);
    }

    @GetMapping("detail")
    public Object detail(Integer id) {

        MarketBrand result = wxBrandService.detail(id);
        // 对数据进行校验
        if (result == null) {
            return ResponseUtil.badArgument();
        }
        return ResponseUtil.ok(result);
    }
}
